home *** CD-ROM | disk | FTP | other *** search
- Path: weck.brokersys.com!not-for-mail
- From: jguthrie@brokersys.com
- Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
- Subject: Re: Hungarian notation
- Date: 4 Jan 1996 09:00:48 -0600
- Organization: Executel/IBS Internet Services
- Message-ID: <4cgq30$c0v@weck.brokersys.com>
- References: <30C40F77.53B5@swsbbs.com> <marnoldDJEvtJ.1Lx@netcom.com> <4aleun$jlk@ns.RezoNet.NET> <marnoldDJMDBG.CFz@netcom.com> <4asnkr$7b0@solutions.solon.com> <4ath75$e7i@barnacle.iol.ie> <4b4kij$svt@news.microsoft.com> <dewar.819489496@schonberg> <4bd <4cf8hf$8fe@hopi.gate.net>
- NNTP-Posting-Host: weck.brokersys.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Michael Feathers (feathers@gate.net) wrote:
- : : Why don't you just abandon the type declarations completely and use a
- : : prefix on the variable names to define the type?
-
- : : My attitude remains the same: Any naming convention works better than
- : : none, but embedding the type in the name is probably a bad idea.
-
- : I really don't see why. Hungarian is particularly useful in the
- : presence of polymorphism.
-
- How does polymorphism make embedding the type in the name particularly useful?
-
- : How can it hurt?
-
- It hurts because you have to keep track of the type independantly of the
- actual type declaration. Having to maintain that information in two places
- means that it won't ever get done. When you change the type of a variable,
- (and this IS done from time to time even after primary coding is finished,)
- not only do you have to change the declaration, but also all the places where
- that variable appears no matter where it is or the information it gives you
- is wrong. Comments that lie are far worse than no comments at all. The
- only description of what the code DOES is in the code itself, the comments
- (and other semantically insignificant clues in the program) should describe
- what the program is trying to accomplish, not how it accomplishes it.
-
- I wasn't quite completely kidding when I suggested replacing normal variable
- declarations with a default type based upon the name prefix, it would be the
- obvious answer to my objection if it wasn't so much easier to just change
- one declaration than a dozen or so appearances.
-
- I should also make it clear that, in the absence of name-based typing, I
- don't think the name of the identifier should be what is used to determine the
- type of the identifier. On the contrary, it should reflect which module (or
- class or whatever the logical unit of functionality your language uses) the
- identifier is associated with (if it's in the global namespace) and it should
- somehow describe the use for which it is intended. I actually liked the way
- that you could do stuff in Modula-2 that looks like
-
- IMPORT Queue;
-
- ...
-
- VAR
- FileList : Queue.Type;
-
- BEGIN
-
- FileList := Queue.Create();
-
- Queue.Add(FileList, OneElement);
- Queue.Add(FileList, AnotherElement);
- Queue.Sort(FileList);
- Queue.Print(FileList);
- Queue.Destroy(FileList);
- END
-
- To be sure, the notation is clumsier than what you might have with C++, but it
- certainly isn't any less clear.
-
- Forgive me for rambling, please.
-